<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="../common/taglibs.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <title>商户释放，分配</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
    <!-- 当前页面样式 -->
    <link rel="stylesheet" href="<s:url value="/css/common.css"/>"/>
    <!-- 当前页面样式 END -->
    <script type="text/javascript" src="<c:url value="/js/jquery-1.3.2.js" />"></script>
	<script type="text/javascript" src="<c:url value="/js/common.js" />"></script>
	<script type="text/javascript" src="<c:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
	<script type="text/javascript">
	$(document).ready(function() {
		$("#szPower").click(
				function() {
					var dd = $("input[name=multi_sel]:checked");
					var accountNoStr= "";
					if(dd.length == 0){
						alert("请选择商户");
						return false;
					}else if(dd.length >= 11){
						alert("最多只能释放十个商户！");
						return false;
					}else{
						
						dd.each(function(){
							accountNoStr = accountNoStr + $(this).val() + ",";
						});
						accountNoStr = accountNoStr.substring(0,accountNoStr.length-1);
						
						
						$.ajax({
							url:"<%=basePath%>/merinfoAlloat/merinfoRelease.ct",
							type:"post",
							data:{"merInfoIdList":accountNoStr},
							dataType:"json",
							success:function(result){
								var rsList = result.rsList;
								if(rsList.length > 0){
									var rsStr = "";
									for(var i = 0;i<rsList.length;i++){
										rsStr = rsStr + rsList[i] + ",";
									}
									rsStr = rsStr.substring(0,rsStr.length-1);
									alert("商户号为：【"+rsStr+"】的商户释放不成功");
									
								}else{
									alert("释放成功！");
									
								}
								window.location.href="<%=basePath%>/merinfoAlloat/queryMerinfoAlloat.ct";
								
							},error:function(){
								alert("未知错误！");
							}
						});
					}
		});
	});	
	


	function queryForm(){
		$("#queryUserForm").attr("action","<%=basePath%>/merinfoAlloat/queryMerinfoAlloat.ct");
		$("#queryUserForm").submit();
		
	}
	
	
	
	$(document).ready(function() {
		$("#alloat").click(
				function() {
				 	var name=$("select[name=alloatSearchCondition.alloatName] option:selected").val();
				 	
					if(name=="99"){
						alert("请选择分配的风控姓名！");
						return;
					}
					
				
					var dd = $("input[name=multi_sel]:checked");
					var accountNoStr= "";
					if(dd.length == 0){
						alert("请选择商户");
						return false;
					}else if(dd.length >= 11){
						alert("最多只分配十个商户！");
						return false;
					}else{
						
						
						dd.each(function(){
							accountNoStr = accountNoStr + $(this).val() + ",";
						});
						accountNoStr = accountNoStr.substring(0,accountNoStr.length-1);	
						
						$.ajax({						
							 url:'<%=basePath%>merinfoAlloat/merinfoAlloat1.ct',
							 type:"post",
							 data:{"merInfoIdList":accountNoStr,"searchCondition.alloatName":name},
							 dataType:"json",
							 success:function(result){
								 
								var rsList = result.resultMap.success;
								var msg = result.resultMap.error;
								if(rsList)
								{
									var rsStr = "";
									for(var i = 0;i<rsList.length;i++){
										rsStr = rsStr + rsList[i] + ",";
									}
								 
									rsStr = rsStr.substring(0,rsStr.length-1);
									alert("商户分配成功");
									
								}else{
									alert(msg);
									
								}
								window.location.href="<%=basePath%>/merinfoAlloat/queryMerinfoAlloat.ct";
								
							},error:function(){
								
								alert("未知错误！");
							}
						});
					}
		});
	})
	


	function queryForm(){
		$("#queryUserForm").attr("action","<%=basePath%>/merinfoAlloat/queryMerinfoAlloat.ct");
		$("#queryUserForm").submit();
		
	}
</script>
</head>
<body>
<s:form id="queryUserForm" action="" method="post" theme="simple">
<table class="tb">
    <tbody>
        <tr class="tb-line">
            <td class="tb-td" colspan="4"><div class="tb-h2">POS收单运营管理平台</div></td>
        </tr>

        <tr class="tb-line">
            <td class="tb-td" colspan="4"><div class="tb-h3">商户释放、分配</div></td>
        </tr>
 
        <tr class="tb-line">
            <td align="right" class="tb-td">
                <div class="tb-h4">商户号：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                	<s:textfield  id="merno" name="searchCondition.merchantNo" />
               	</label>
            </td>
             <td align="right" class="tb-td">
                <div class="tb-h4">商户简称：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                	<s:textfield  name="searchCondition.merchantName" maxlength="20"/>
                </label>
            </td>
        </tr>

        <tr class="tb-line">
            <td align="right" class="tb-td">
                <div class="tb-h4">营业名称：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                	<s:textfield  name="searchCondition.merBrName" maxlength="25"/>
                </label>
            </td>
            <td align="right" class="tb-td">入网时间：</td>
			<td class="tb-td" >
				 <label class="tb-input-normal">
					<s:textfield    onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,wdate:true,errDealMode:0});"    name="searchCondition.minDate"  />
				 </label>
				-
				 <label class="tb-input-normal">
					<s:textfield  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,wdate:true,errDealMode:0});"   name="searchCondition.maxDate"   />
				</label>
			</td>
        </tr>
		<tr class="tb-line">
            <td align="right" class="tb-td">
                <div class="tb-h4">法人名称：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                	<s:textfield  name="searchCondition.certifName" maxlength="25"/>
               	</label>
            </td>
             <td align="right" class="tb-td">
                <div class="tb-h4">法人身份证：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                	<s:textfield  name="searchCondition.cardNo" maxlength="20"/>
                </label>
            </td>
        </tr>
        <tr class="tb-line">
            <td align="right" class="tb-td">
                <div class="tb-h4">业务联系人名称：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                	<s:textfield  name="searchCondition.contactName" maxlength="25"/>
               	</label>
            </td>
             <td align="right" class="tb-td">
                <div class="tb-h4">业务联系人手机号：</div>
            </td>
            <td class="tb-td">
                <label class="tb-input-normal">
                	<s:textfield  name="searchCondition.phone" maxlength="15" />
                </label>
            </td>
         </tr>
              <tr class="tb-line" >
                   <td  align="right" class="tb-td"  >
                        <div class="tb-h4">分配风控姓名：</div>
                    </td>
                     <td class="tb-td">
                		<label class="tb-select">
							
								<s:select cssClass="queryWidth" name="alloatSearchCondition.alloatName"
									list="riskList" listKey="realName" listValue="realName" 
									headerKey="99" headerValue="--请选择--" />
	                       
							
					     </label>
            		</td>
                </tr>
        
        

        <tr class="tb-line">
            <td class="tb-td line-submit" align="right" colspan="4">
                <label class="tb-input-submit">
                    <input type="button" value="查 询"  onclick='queryForm()'/>
                </label>
                <label class="tb-input-submit">
                    <input type="reset" value="取 消"/>
                </label>
                <label class="tb-input-submit">
                    <input id="szPower" type="button"  value="释 放" />
                </label>
                <label class="tb-input-submit">
                    <s:if test="#request.searchRsList != null && #request.searchRsList.size>0">  
                    	<input id="alloat" type="button"  value="分 配" />
					</s:if>			
					<s:else>
					<input id="alloat" type="button" disabled="true"  value="分 配" />
					</s:else>
					
                </label>
            </td>
        </tr>
        <s:if test="#request.searchRsList != null && #request.searchRsList.size>0 ">     
			<tr class="tb-line">
				<td class="tb-td paging"  align="left" colspan="4"> 
					 	<page:pageCount max_pages="11" totalPage="${requestScope.totalPage}"
						currentPage="${requestScope.currentPage}"
						action="${rootPath}/merinfoAlloat/queryMerinfoAlloat.ct?currentPage=" />

				</td>
			</tr>
		</s:if>
    </tbody>
</table>
</s:form>
<div class="big-tb">
    <table class="tb" style="width: 150%;">
        <thead>
            <tr class="tb-line">
                <th class="tb-th" colspan="16">商户基本信息列表</th>
            </tr>
            <tr class="tb-line bg-gray">
                <th class="tb-th">选择</th>
				<th class="tb-th">商户号</th>
				<th class="tb-th">商户简称</th>
				<th class="tb-th">营业名称</th>
				
				<th class="tb-th">所属机构</th>
				<th class="tb-th">所属代理商</th>
				<th class="tb-th">状态</th>
				<th class="tb-th">业务联系人</th>
				<th class="tb-th">业务联系人电话</th>
				<th class="tb-th">法人</th>
				<th class="tb-th">法人证件号</th>
				<th class="tb-th">结算银行</th>
				<th class="tb-th">联行号</th>
				<th class="tb-th">结算银行账号名称</th>
				<th class="tb-th">结算银行账号</th>
				<th class="tb-th">商户地址</th>
				
            </tr>
        </thead>
        <tbody>
			<s:iterator value="#request.searchRsList" status="stat" id="sh">
				<tr class="tb-line" >
					<td align="center" class="tb-td">

						<input   name="multi_sel" value="<s:property value="#sh.mid"/>" type="checkbox" />
			        </td>
					<td class="tb-td"><s:property value="#sh.mid"/></td>
					<td class="tb-td"><s:property value="#sh.merName"/></td>
			        <td class="tb-td"><s:property value="#sh.merBrName"/></td>
			      
			        <td class="tb-td"><s:property value="#sh.merKind"/> </td>
			         <td class="tb-td"><s:property value="#sh.agentId"/> </td>
			         <td class="tb-td"><s:property value="#sh.flag"/> </td> 
			        <td class="tb-td"><s:property value="#sh.perName"/></td>
			        <td class="tb-td"><s:property value="#sh.perPhone"/></td>
			        <td class="tb-td"><s:property value="#sh.interContact"/></td>
			        <td class="tb-td"><s:property value="#sh.cardNo"/></td>
			        <td class="tb-td"><s:property value="#sh.amount1"/></td>
			        <td class="tb-td"><s:property value="#sh.amount2"/></td>
			        <td class="tb-td"><s:property value="#sh.rsvl"/></td>
			        <td class="tb-td"><s:property value="#sh.rsvl3"/></td>
			        <td class="tb-td"><s:property value="#sh.addr"/></td>
			        
			      </tr>
			</s:iterator>	
        </tbody>
    </table>
   
</div>
 <s:if test="#request.msg !=null">
		<script language="javascript">
			alert("${request.msg}");
		</script>
	</s:if>
</body>
</html>